package priv.amos.androidnetwork.connector;

import java.util.List;

import priv.amos.androidnetwork.bean.AndroidConnection;
import priv.amos.androidnetwork.filter.DataFilter;
import priv.amos.androidnetwork.type.ConnMethodType;
import cz.msebera.android.httpclient.NameValuePair;
import android.content.Context;
import android.os.Handler;

public class DataNetWorkConnector {
	private ConnectionProcessor cp;
	private Context ctx;
	public DataNetWorkConnector(Context ctx,int connThreadsSize,int connTimeout,int soTimeout){
		cp=new ConnectionProcessor(connThreadsSize,connTimeout,soTimeout);
		this.ctx=ctx;
	}
	public void getNetWorkData(String url,String dataType,Handler h,int timeoutInMilisec){
		AndroidConnection conn=new AndroidConnection();
		conn.setConnectionType(ConnMethodType.GET);
		conn.setCtx(ctx);
		conn.setDataType(dataType);
		conn.setH(h);
		conn.setTimeoutinmiliseconds(timeoutInMilisec);
		conn.setUrl(url);
		cp.newConnection(conn);
	}
	public void startNetworkCookies(Context ctx){
		cp.startCookies(ctx);
	}
	public void endNetworkCookie(Context ctx){
		cp.endCookies(ctx);
	}
	public void postNetWorkData(String url,String dataType,List<NameValuePair> nvps,Handler h){
		AndroidConnection conn=new AndroidConnection();
		conn.setConnectionType(ConnMethodType.POST);
		conn.setCtx(ctx);
		conn.setDataType(dataType);
		conn.setH(h);
		conn.setNvps(nvps);
		conn.setUrl(url);
		cp.newConnection(conn);
	}
}
